package org.ouwh.oowiki.ctrl;

import org.ouwh.fw.model.data.List;
import org.ouwh.fw.model.data.Struct;
import org.ouwh.oowiki.http.MyException;
import org.ouwh.oowiki.http.MyRequest;
import org.ouwh.oowiki.http.MyResponse;

public class EchoController extends AbstractController {

	@Override
	protected MyResponse invoke(MyRequest request) throws MyException {
		MyResponse response = new MyResponse();
		Struct param = request.getParameters();
		response.setResults(param);

		// complex data sample 1
		Struct complexDataShow1 = new Struct("complexDataShow1");
		complexDataShow1.addData("c1", "hello world1");
		Struct complexDataShow11 = new Struct("complexDataShow1-1");
		complexDataShow11.addData("c1-1", "hello world1");
		complexDataShow1.addData(complexDataShow11);
		response.add(complexDataShow1);

		// complex data sample 2
		List complexDataShow2 = new List();
		complexDataShow2.setName("complexDataShow2");
		complexDataShow2.add(complexDataShow11);
		complexDataShow2.add(complexDataShow11);
		response.add(complexDataShow2);

		return response;
	}
}
